/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.kiakaku.Graph;

import java.io.Serializable;

/*
 *   File Edge is created by kiakaku on Feb 15, 2012 9:06:18 PM
 * If you want modify this file please insert information in here 
 * - Last modify in Feb 15, 2012, 9:06:18 PM by kiakaku
 *                  
 *
 * @author kiakaku
 */
public class Edge<T> implements Serializable{

    private Vertex<T> from;
    private Vertex<T> to;
    private int cost;
    private boolean mark;

    public Edge(Vertex<T> from, Vertex<T> to) {
        this(from, to, 0);
    }

    public Edge(Vertex<T> from, Vertex<T> to, int cost) {
        this.from = from;
        this.to = to;
        this.cost = cost;
        mark = false;
    }

    public Vertex<T> getTo() {
        return to;
    }

    public Vertex<T> getFrom() {
        return from;
    }

    public int getCost() {
        return cost;
    }

    public void mark() {
        mark = true;
    }

    public void clearMark() {
        mark = false;
    }

    public boolean isMarked() {
        return mark;
    }
    public String toString() {
    StringBuffer tmp = new StringBuffer("Edge[from: ");
    tmp.append(from.getName());
    tmp.append(",to: ");
    tmp.append(to.getName());
    tmp.append(", cost: ");
    tmp.append(cost);
    tmp.append("]");
    return tmp.toString();
  }
}
